package ${pkg}.action.${name};

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.kool.core.base.IBaseAction;
import com.kool.core.exception.AppException;
import com.kool.core.util.BeanUtils;
import ${pkg}.bean.${upTumTabNam}Bean;
import ${pkg}.bean.io.${name}.${updateIn}Bean;
import ${pkg}.service.${businessName}Service;

/**
 * @DESCRIBE 修改
 * @AUTHOR LUYU
 */
@Controller
public class Update${businessName}Action implements IBaseAction {
	@Autowired
	private ${businessName}Service service;

	@Override
	@ResponseBody
	@RequestMapping(value = "${updateUrl}", method = RequestMethod.POST)
	public JSONObject doAction(@RequestBody String sInput) throws AppException {
		JSONObject pkgIn = JSONObject.parseObject(sInput);
		JSONArray secIn = pkgIn.getJSONArray("${updateIn}");
		if (null == secIn || secIn.size() <= 0) {
			throw new AppException("SY000047");// 输入为空
		}
		JSONObject propIn = secIn.getJSONObject(0);
		${updateIn}Bean ioIn = JSON.toJavaObject(propIn, ${updateIn}Bean.class);
		ioIn.validate();

		${upTumTabNam}Bean beanIn = (${upTumTabNam}Bean) BeanUtils.io2Bean(ioIn, ${upTumTabNam}Bean.class, "${prefix}");
		service.update(beanIn);

		return null;
	}

}
